package cn.jtcoding.test.aspect;

import cn.jtcoding.springframework.core.annotation.Component;
import cn.jtcoding.springframework.aop.annotation.Aspect;
import cn.jtcoding.springframework.aop.annotation.Order;
import cn.jtcoding.springframework.aop.aspect.DefaultAspect;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Method;

@Slf4j
@Order(2)
@Aspect(Component.class)
@Component
public class ComponentAspect extends DefaultAspect {
    @Override
    public void before(Class<?> clazz, Method method, Object[] args) throws Throwable {
        log.info("执行 Component Aspect 前置通知, Class: {}, method: {}", clazz.getName(), method.getName());
    }

    @Override
    public Object afterReturning(Class<?> clazz, Method method, Object[] args, Object returnValue) throws Throwable {
        log.info("执行 Component Aspect 后置通知, Class: {}, method: {}, return obj: {}", clazz.getName(), method.getName(), returnValue);
        return returnValue;
    }
}
